#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main()
{
    int a = 0;
    int b = 0;
    scanf("%d %d", &a, &b);

    int arr[10][10];
    for (int i = 0; i < a; i++)
    {
        for (int j = 0; j < b; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }

    int count = 0;
    char com = 0;
    int one = 0;
    int two = 0;
    scanf("%d", &count);
    while (count--)
    {
        getchar();
        scanf("%c %d %d", &com, &one, &two);
        if (com == 'r')
        {
            for (int j = 0; j < b; j++)
            {
                int temp = 0;
                temp = arr[one - 1][j];
                arr[one - 1][j] = arr[two - 1][j];
                arr[two - 1][j] = temp;
            }
        }
        else if (com == 'c')
        {
            for (int i = 0; i < a; i++)
            {
                int temp = 0;
                temp = arr[i][two - 1];
                arr[i][two - 1] = arr[i][one - 1];
                arr[i][one - 1] = temp;
            }
        }
        else
        {
            ;
        }
    }

    for (int i = 0; i < a; i++)
    {
        for (int j = 0; j < b; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}